package cn.lzd.mvp.base;

import android.app.Application;
import cn.lzd.mvp.base.net.NetManager;
import cn.lzd.mvp.base.net.RxUtils;
import com.blankj.utilcode.util.ToastUtils;
import io.reactivex.plugins.RxJavaPlugins;

public class MVPApplication extends Application {

    static {
        // 全局捕获未预料的异常
        RxJavaPlugins.setErrorHandler(throwable -> RxUtils.getErrorMessageToShow(throwable, ToastUtils::showShort));
    }

    @Override
    public void onCreate() {
        super.onCreate();
        NetManager.init();
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        NetManager.release();
    }
}
